﻿namespace h5
{
    public class Rect
    {
        private double _width;
        private double _height;

        public Rect()
        {
            _width = 10;
            _height = 10;
        }

        public Rect(double width, double height)
        {
            _width = width;
            _height = height;
        }

        public double Width
        {
            get { return _width; }
            set { _width = value; }
        }

        public double Height
        {
            get { return _height; }
            set { _height = value; }
        }

        public double Area()
        {
            return _width * _height;
        }

        public double Perimeter()
        {
            return 2 * (_width + _height);
        }
    }

    public class PlainRect : Rect
    {
        private double _startX;
        private double _startY;

        public PlainRect() : base(0, 0)
        {
            _startX = 0;
            _startY = 0;
        }

        public PlainRect(double startX, double startY, double width, double height) : base(width, height)
        {
            _startX = startX;
            _startY = startY;
        }

        public double StartX
        {
            get { return _startX; }
            set { _startX = value; }
        }

        public double StartY
        {
            get { return _startY; }
            set { _startY = value; }
        }

        public bool IsInside(double x, double y)
        {
            return (x >= _startX && x <= _startX + Width) &&
                   (y >= _startY && y <= _startY + Height);
        }
    }

    internal class Program
    {
        public static void Main(string[] args)
        {
            PlainRect rect = new PlainRect(10, 10, 20, 10);

            Console.WriteLine($"矩形信息：StartX = {rect.StartX} StartY = {rect.StartY}");
            Console.WriteLine($"矩形宽度 = {rect.Width} 矩形长度 = {rect.Height}");
            Console.WriteLine($"面积：{rect.Area()}");
            Console.WriteLine($"周长：{rect.Perimeter()}");

            double testX = 25.5;
            double testY = 13;
            bool isInside = rect.IsInside(testX, testY);

            if (isInside)
            {
                Console.WriteLine($"点({testX}, {testY})在矩形内部");
            }
            else
            {
                Console.WriteLine($"点({testX}, {testY})不在矩形内部");
            }

            testX = 13;
            testY = 25.5;
            isInside = rect.IsInside(testX, testY);

            if (isInside)
            {
                Console.WriteLine($"点({testX}, {testY})在矩形内部");
            }
            else
            {
                Console.WriteLine($"点({testX}, {testY})不在矩形内部");
            }
        }
    }
}
